home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / gravity.swf / scripts / frame_111 / PlaceObject2_81_45 / CLIPACTIONRECORD onClipEvent(enterFrame).as next >
Encoding:
Text File  |  2007-03-28  |  5.4 KB  |  229 lines

  1. onClipEvent(enterFrame){
  2.    function rotate(rvar)
  3.    {
  4.       _rotation = _rotation + 3 * rvar;
  5.       if(_rotation < 0)
  6.       {
  7.          myRotation = 360 + _rotation;
  8.       }
  9.       else
  10.       {
  11.          myRotation = _rotation;
  12.       }
  13.    }
  14.    function constant()
  15.    {
  16.       myXMomentum += myXMovement - myXGravity;
  17.       myYMomentum += myYMovement - myYGravity;
  18.       if(this._x + myXMomentum >= 425 || 175 >= this._x + myXMomentum)
  19.       {
  20.          _parent.foreground._x -= myXMomentum;
  21.          Xparticleshift = myXMomentum;
  22.       }
  23.       else
  24.       {
  25.          this._x += myXMomentum;
  26.          Xparticleshift = 0;
  27.       }
  28.       if(this._y + myYMomentum >= 225 || 175 >= this._y + myYMomentum)
  29.       {
  30.          _parent.foreground._y -= myYMomentum;
  31.          Yparticleshift = myYMomentum;
  32.       }
  33.       else
  34.       {
  35.          this._y += myYMomentum;
  36.          Yparticleshift = 0;
  37.       }
  38.    }
  39.    function explode()
  40.    {
  41.       if(60 >= i)
  42.       {
  43.          duplicateMovieClip(_parent.particle,"mcc" + i,16384 + i);
  44.          _parent["mcc" + i].myGocommand = "blow";
  45.          i++;
  46.          blowdelay++;
  47.          if(i >= 20)
  48.          {
  49.             this.gotoAndStop(2);
  50.          }
  51.       }
  52.    }
  53.    function engineburn()
  54.    {
  55.       if(myPartAmount >= i)
  56.       {
  57.          duplicateMovieClip(_parent.particle,"mc" + i,16384 + i);
  58.          _parent["mc" + i].myGocommand = "go";
  59.          _parent["mc" + i]._x = _X;
  60.          _parent["mc" + i]._y = _Y;
  61.          i++;
  62.       }
  63.       else
  64.       {
  65.          i = 0;
  66.       }
  67.    }
  68.    function sputDirection()
  69.    {
  70.       origin_x2 = _parent[target]._x;
  71.       origin_y2 = _parent[target]._y;
  72.       mouse_x2 = this._x;
  73.       mouse_y2 = this._y;
  74.       dist_x2 = mouse_x2 - origin_x2;
  75.       dist_y2 = mouse_y2 - origin_y2;
  76.       if(Number(dist_x2) < 0)
  77.       {
  78.          normalise2 = -1 * dist_x2;
  79.       }
  80.       else
  81.       {
  82.          normalise2 = dist_x2;
  83.       }
  84.       if(Number(dist_y2) < 0)
  85.       {
  86.          normalise2 = Number(normalise2) + Number(-1 * dist_y2);
  87.       }
  88.       else
  89.       {
  90.          normalise2 = Number(normalise2) + Number(dist_y2);
  91.       }
  92.       if(Number(dist_x2) >= 0 and Number(dist_y2) >= 0)
  93.       {
  94.          direction2 = 90 * (dist_y2 / normalise2);
  95.       }
  96.       else if(0 >= Number(dist_x2) and Number(dist_y2) >= 0)
  97.       {
  98.          direction2 = Number(-90 * (dist_x2 / normalise2)) + 90;
  99.       }
  100.       else if(0 >= Number(dist_x2) and 0 >= Number(dist_y2))
  101.       {
  102.          direction2 = Number(-90 * (dist_y2 / normalise2)) + 180;
  103.       }
  104.       else
  105.       {
  106.          direction2 = Number(90 * (dist_x2 / normalise2)) + 270;
  107.       }
  108.       _root.sputnikfinder._rotation = direction2;
  109.    }
  110.    function gravity()
  111.    {
  112.       origin_x = _root.foreground._x;
  113.       origin_y = _root.foreground._y;
  114.       mouse_x = this._x;
  115.       mouse_y = this._y;
  116.       dist_x = mouse_x - origin_x;
  117.       dist_y = mouse_y - origin_y;
  118.       if(Number(dist_x) < 0)
  119.       {
  120.          normalise = -1 * dist_x;
  121.       }
  122.       else
  123.       {
  124.          normalise = dist_x;
  125.       }
  126.       if(Number(dist_y) < 0)
  127.       {
  128.          normalise = Number(normalise) + Number(-1 * dist_y);
  129.       }
  130.       else
  131.       {
  132.          normalise = Number(normalise) + Number(dist_y);
  133.       }
  134.       if(Number(dist_x) >= 0 and Number(dist_y) >= 0)
  135.       {
  136.          direction = 90 * (dist_y / normalise);
  137.       }
  138.       else if(0 >= Number(dist_x) and Number(dist_y) >= 0)
  139.       {
  140.          direction = Number(-90 * (dist_x / normalise)) + 90;
  141.       }
  142.       else if(0 >= Number(dist_x) and 0 >= Number(dist_y))
  143.       {
  144.          direction = Number(-90 * (dist_y / normalise)) + 180;
  145.       }
  146.       else
  147.       {
  148.          direction = Number(90 * (dist_x / normalise)) + 270;
  149.       }
  150.       myYGravity = Math.sin(0.017453292519943295 * direction) * myGrav;
  151.       myXGravity = Math.cos(0.017453292519943295 * direction) * myGrav;
  152.       _parent.planetfinder._rotation = direction;
  153.    }
  154.    if(WinLose == "lose")
  155.    {
  156.       if(myFailTime)
  157.       {
  158.          if(getTimer() - myFailtime >= 5000)
  159.          {
  160.             myLanded = "stop";
  161.             _parent.popup.gotoAndStop("loser");
  162.          }
  163.       }
  164.       else
  165.       {
  166.          myFailtime = getTimer();
  167.          _root.Angry.go = "stop";
  168.       }
  169.    }
  170.    else if(WinLose == "win")
  171.    {
  172.       if(myWinTime)
  173.       {
  174.          if(getTimer() - myWinTime >= 2000)
  175.          {
  176.             myLanded = "stop";
  177.             _parent.popup.gotoAndStop("winner");
  178.          }
  179.       }
  180.       else
  181.       {
  182.          myWinTime = getTimer();
  183.          _root.Angry.go = "stop";
  184.       }
  185.    }
  186.    if(exploding == "true")
  187.    {
  188.       explode();
  189.       gravity();
  190.       constant();
  191.       myXMovement = 0;
  192.       myYMovement = 0;
  193.       WinLose = "lose";
  194.    }
  195.    if(myLanded == "go")
  196.    {
  197.       gravity();
  198.       constant();
  199.       sputDirection();
  200.       if(key.isDown(38))
  201.       {
  202.          myVelocity = 0.2;
  203.          engineburn();
  204.          myXMovement = Math.cos(0.017453292519943295 * myRotation) * myVelocity;
  205.          myYMovement = Math.sin(0.017453292519943295 * myRotation) * myVelocity;
  206.       }
  207.       else
  208.       {
  209.          myXmovement = 0;
  210.          myYmovement = 0;
  211.       }
  212.       if(key.isDown(37))
  213.       {
  214.          rotate(-1);
  215.       }
  216.       if(key.isDown(39))
  217.       {
  218.          rotate(1);
  219.       }
  220.    }
  221.    else if(myLanded == "stop")
  222.    {
  223.       myXmovement = 0;
  224.       myYmovement = 0;
  225.       myXMomentum = 0;
  226.       myYMomentum = 0;
  227.    }
  228. }
  229.